<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/prettyphoto.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.prettyphoto.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.mselect.js?"></script>
<script type="text/javascript">
$(function(){
	var purchase_categories_data = <?=$purchase_categories?>;
	$(document).mselect(purchase_categories_data, 'product_categories_id','product_categories_id', "<?=isset($_GET['product_categories_id'])?$_GET['product_categories_id']:0?>");
	$("a[rel^='pretty_photo']").prettyPhoto({theme:'facebook'});
	$(".datepicker").datepicker({dateFormat:'yy-mm-dd',changeMonth:true});
});
</script>
<fieldset><legend>查询条件</legend>
<form method="get">
<? include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
<tr>
	<th>销售日期</th>
	<td>
		<input type="text" name="begin_sales_time" class="datepicker" value="<?=isset($_GET['begin_sales_time'])?$_GET['begin_sales_time']:''?>" /> to 
		<input type="text" name="end_sales_time" class="datepicker" value="<?=isset($_GET['end_sales_time'])?$_GET['end_sales_time']:''?>" />
	</td>
</tr>
<tr>
	<th>产品类别</th>
	<td colspan="3"><input type="hidden" name="product_categories_id" id="product_categories_id" /></td>
</tr>
<tr>
	<th>网站</th>
	<td>
		<select name="shop_id">
			<option value="">请选择..</option>
			<?foreach ($shop as $s):?>
			<option value="<?=$s['id']?>" <?if (isset($_GET['shop_id']) && $s['id']==$_GET['shop_id'])echo "selected='selected'"?>><?=$s['name']?></option>
			<?endforeach;?>
		</select>
	</td>
</tr>
<tr>
	<td><input type="hidden" name="is_search" value="1" /></td>
	<td><input type="submit" class="button" value="查询" /></td>
</tr>
</table>
</form></fieldset>

<?if (isset($customer)):?>
<table width="100%" class="list_table">
<?foreach ($customer as $c):?>
<tr>
	<td align="left" colspan="7"><b>姓名：<?=$c['fullname']?> | 邮箱：<?=$c['email']?> | 国家： <?=$c['country']?> | 购买次数：<?=$c['count']?></b></td>
</tr>
<?foreach ($c['order'] as $co):?>
<tr>
	<td rowspan="<?=count($co['item'])?>" width="100"><a target="_blank" href="<?=url('sales::order/list', array('number'=>$co['number']))?>"><?=$co['number']?></a></td>
	<td rowspan="<?=count($co['item'])?>" width="130"><?=$co['sales_time']?></td>
<?foreach ($co['item'] as $k => $coi):?>
<?if($k>=1):?>
<tr>
<?endif;?>
	<td width="70">
		<?=$coi['number']?>
		<?if ($coi['pic_url']):?>
		<?$pretty_photo_number = 0;?>
		<?foreach ($coi['pic_url'] as $coip):?>
		<a rel="pretty_photo[<?=$coi['id']?>_<?=$coi['product_basic_id']?>]" href="<?=$coip?>"><?if(!$pretty_photo_number):?><span class="img_icon"></span><?endif;?></a>
		<?$pretty_photo_number = 1;?>
		<?endforeach;?>
		<?endif;?>
	</td>
	<td align="left"><?=$coi['name']?></td>
	<td width="40"><?=$coi['quantity']?></td>
	<td width="60"><?=$co['symbol']?><?=sprintf('%.2f', $coi['sales_price'])?></td>
	<?if ($k==0):?><td width="70" rowspan="<?=count($co['item'])?>"><?=$co['symbol']?><?=sprintf('%.2f', $co['amount'])?></td><?endif;?>
</tr>
<?endforeach;?>
<?endforeach;?>
<?endforeach;?>
</table>
<?endif;?>
<?php $this->_endblock();?>